<#assign
        packageModel=projPackage.projPackage + "." + projPackage.entity
        packageService=projPackage.projPackage + "." + projPackage.service
        packageController=projPackage.projPackage + "." + projPackage.controller
        packageUtils=projPackage.projPackage + "." + projPackage.utils
        >
package ${packageController};

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import ${packageModel}.${billInfo.billClass};
import ${packageService}.${billInfo.billClass}Service;
import ${packageUtils}.JsonResult;

// 版本号：20240401
@Api(tags = "单据后台 - ${billInfo.billRemark}")
@CrossOrigin
@RestController
@RequestMapping("/${billInfo.billClass?uncap_first}")
public class ${billInfo.billClass}Controller {
    @Autowired
    private ${billInfo.billClass}Service service;

    // 根据主键删除，切记表要有主键，否则为删除所有数据！！！！！！！！！！
    @ApiOperation(value = "根据主键删除", httpMethod = "POST", notes = "所有请求都是post")
    @PostMapping("/delete/{pk}")
    public JsonResult deleteByPrimaryKey(@PathVariable Long pk){
        return JsonResult.ok(service.delete(pk));
    }

    // 根据主键查询，切记表要有主键，否则为查询所有数据！！！！！！！！！！
    @ApiOperation(value = "根据主键查询", httpMethod = "POST", notes = "所有请求都是post")
    @PostMapping("/select/{pk}")
    public JsonResult selectByPrimaryKey(@PathVariable Long pk){
        return JsonResult.ok(service.selectByPrimaryKey(pk));
    }

    // 有则修改，无则新增。选择性保存，如果属性value=null则不会更新该字段
    @ApiOperation(value = "保存数据", httpMethod = "POST", notes = "主键为空则新增(选择性新增)，主键有值则修改（选择性修改）,主表明细表都遵循该规则，" +
            "传入参数案例：{\"main\":{\"projectId\":1},\"detailList\":[{\"produceDate\":\"2023-02-16\",\"managementNumber\":\"99-024A-02\",\"team01\":\"A\",\"team02\":\"早\",\"lineId\":1,\"goodsSid\":\"057BC07N(外)\",\"qtyProduct\":3200,\"qtyProductDefect\":3,\"detailList\":[{\"defectId\":1,\"qty\":1},{\"defectId\":2,\"qty\":2}]},{\"produceDate\":\"2023-02-16\",\"managementNumber\":\"99-024A-02\",\"team01\":\"A\",\"team02\":\"中\",\"lineId\":1,\"goodsSid\":\"057BC07N(外)\",\"qtyProduct\":3200,\"qtyProductDefect\":5,\"detailList\":[{\"defectId\":1,\"qty\":2},{\"defectId\":2,\"qty\":1},{\"defectId\":3,\"qty\":2}]}]}")
    @PostMapping("/save")
    public JsonResult save(@RequestBody ${billInfo.billClass} record) {
        return JsonResult.ok(service.save(record));
    }
    //=================以上是自动生成的代码，自定义代码请写在下面==================

    @ApiOperation(value = "移动单据：prev(上一单v、next(下一单)、first(首单)、last(末单)", httpMethod = "POST", notes = "请求上一单的参数:{\"id\":12,\"moveBillFlag\":\"prev\"}，请求下一单的参数：{\"id\":12,\"moveBillFlag\":\"next\"}，请求首单参数：{\"moveBillFlag\":\"first\"}，请求末单参数：{\"moveBillFlag\":\"last\"}")
    @PostMapping("/moveBill")
    public JsonResult moveBill(@RequestBody Map<String,Object> params) {
        Long id = (Long) params.get("id");
        String flag = (String) params.get("moveBillFlag");
        return JsonResult.ok(service.moveBill(id,flag));
    }
}
